package com.hankol.newretail.adapter

import android.widget.ImageView
import com.baselibrary.extension.checkValue
import com.baselibrary.utils.CommonUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.newretail.R
import com.hankol.newretail.bean.AddressData
import com.baselibrary.bean.ReceiveAddressBean

/*收货地址 列表 */
class ReceiveAddreessListAdapter :
    BaseQuickAdapter<ReceiveAddressBean, BaseViewHolder>(R.layout.item_receive_address) {

    override fun convert(helper: BaseViewHolder, item: ReceiveAddressBean) {
        helper.apply {
            item.let {
                setText(R.id.tv_name_phone, "${it.name} ${it.phone}")
                setText(R.id.tv_detail, "${CommonUtil.jsonToBean(it.areaFirst, AddressData::class.java).name.checkValue()}${CommonUtil.jsonToBean(it.areaSecond, AddressData::class.java).name.checkValue()}${CommonUtil.jsonToBean(it.areaThree, AddressData::class.java).name.checkValue()}${it.address}")
                val imgDef = getView<ImageView>(R.id.img_def)
                imgDef.isSelected = it.def == 1
                setGone(R.id.tv_use_ing, it.useing)
                addOnClickListener(R.id.tv_edit)
                addOnClickListener(R.id.tv_delete)
                addOnClickListener(R.id.img_def)
                addOnClickListener(R.id.tv_def)
            }
        }
    }
}